#include<iostream>
#include<format>
using namespace std;
int main()
{
  int a,b,c,d,e;
  int i;
  cin>>a>>b>>c>>d>>e;
  b+=a/3;
  e+=a/3;
  i+=a%3;
  a/=3; 

  c+=b/3;
  a+=b/3;
  i+=b%3;
  b/=3;

  d+=c/3;
  b+=c/3;
  i+=c%3;
  c/=3;

  e+=d/3;
  c+=d/3;
  i+=d%3;
  d/=3;

  a+=e/3;
  d+=e/3;
  i+=e%3;
  e/=3;

cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<endl;
cout<<i;
}
